package com.ht.module.sys.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import com.ht.module.sys.service.ISysDictItemService;
import com.ht.util.*;
import com.ht.module.sys.entity.SysDictItem;
import java.util.*;


/**
 * <p>
 * 字典项表 前端控制器
 * </p>
 *
 * @author Auto-generator
 * @since 2021-05-19
 */
@Api(tags = "字典项表 ")
@RestController
@RequestMapping("/sys-dict-item")
public class SysDictItemController {

    
    @Autowired
    private ISysDictItemService iSysDictItemService;

    


    /**
    * 列表查询
    */
    @ApiOperation(value = "列表查询")
    @GetMapping("/findList")
    public JsonResult findList(SysDictItem en){
        return JsonResult.success(iSysDictItemService.findList(en));
    }




    /**
    * 新增
    */
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public JsonResult add(@RequestBody  @Validated SysDictItem sysDictItem){
        CommMethod.beanCreate(sysDictItem);
        iSysDictItemService.save(sysDictItem);
        return JsonResult.success();
    }

    /**
    * 通过id删除
    */
    @DeleteMapping("/delete-by-id/{id}")
    @ApiOperation(value = "删除")
    public JsonResult delete(@PathVariable(value = "id") String id){
        iSysDictItemService.removeById(id);
        return JsonResult.success();
    }

    /**
    * 修改
    */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JsonResult updateById(@RequestBody @Validated SysDictItem sysDictItem){
        CommMethod.beanUpdate(sysDictItem);
        iSysDictItemService.updateById(sysDictItem);
        return JsonResult.success();
    }

}
